<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>项目产品报价方案</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>

<script type="text/javascript">
	var prjId='${prjId}';
	var prjPrdId='${prjPrdId}';
	var prdFlag='${prdFlag}';
	var detailFlag='${detailFlag}';
	var quotePrpsExist='${quotePrpsExist}';
	var grid = null;
	var quoteGrid = null;
	$(function () {
		initGrid();//grid
		//initQuoteGrid();//报价版支付表信息
		if(detailFlag=="true"){
			$("#removeBtn").hide();
		}
	if(quotePrpsExist==CommonConstant.C_YN_Y){
			$("#quatPrps").show();
		}else{
			$("#quatPrps").hide();
		}
	});
	
	//初始化列表
	function initGrid(){
		var params = {};
		if(prdFlag){
		params.prjPrdId = prjPrdId;
		}else{
		params.prjId = prjId;
		}
		$("#grid").ligerGrid({
	    	url: '<%=path%>/project/prjprddtl/initPayList.do',
	    	method : 'get',
	    	parms:params,
	        columns: [
	            { display: '支付表编号', name: 'paySchNo', minWidth: 140,
	            	render: function (rowdata, rowindex, value, column) { 
	            		var h = '';
	            	       if(rowdata.paySchNo){
		                        h+='<a class="sq-button-hasicon" href="javascript:detailBtn(';
		                        h+="'"+rowdata.id+"',";
		                        if(rowdata.paySchId){
		                        h+="'"+rowdata.paySchId+"',";
		                        }else{
		                        	 h+="'',";
		                        }
		                        h+="'"+rowdata.prjPrdId+"'";
		                        h+=')">'+value+'</a>'
		                        }
	                        return h;
	            		}
	            },
	            { display: '产品名称', name: 'prdNm', minWidth: 200 ,enabledSort:true},
	            { display: '产品型号', name: 'prdMdl', minWidth: 140,enabledSort:true},
	            { display: '产品数量', name: 'prdQty', minWidth: 80 , enabledSort:true},
	             {
	                display: '操作',
	                isSort: false,
	                width: 200,
	                render: function (rowdata, rowindex, value){
	                	  var h="";
	                	  if(detailFlag!="true"){
	                		  <sys:FlowFrmAth preTaskIds="${preTaskIds}" athCd="addPrjBscInfo" pInstId="${pInstId}">
                              if ('${prjTypeCd}' != 'CDDYWYQ') {
                                  h = '<a class="sq-button-hasicon" href="javascript:modifyBtn(';
                                  h += "'" + rowdata.id + "',";
                                  if (rowdata.paySchId) {
                                      h += "'" + rowdata.paySchId + "',";
                                  } else {
                                      h += "'',";
                                  }
                                  h += "'" + rowdata.prjPrdId + "'";
                                  h += ')"><i class="sqBtnIco_4"></i>修改</a>';
                              }
	                		  </sys:FlowFrmAth>
	                	  }
	                    return h;
	                }
	            }  
	        ],
	        pageSize:100,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        heightDiff:-2,
	        checkbox:false,
	        allowUnSelectRow: true,
            alternatingRow: true,
	        rownumbers:true,
	        enabledEdit: true,
	        //usePagerOnLessPagesize: false,
	    });
		grid = liger.get("grid");
		  //grid.setHeight(300);
	}
	
	//报价版支付表信息
	function initQuoteGrid(){
		var params = {};
		if(prdFlag){
		params.prjPrdId = prjPrdId;
		}else{
		params.prjId = prjId;
		}
		$("#quateGrid").ligerGrid({
	    	url: '<%=path%>/project/prjprddtl/initList.do',
	    	method : 'get',
	    	parms:params,
	        columns: [
	            { display: '支付表编号', name: 'paySchNo', minWidth: 140,
	            	render: function (rowdata, rowindex, value, column) { 
	            		var h = '';
	            	       if(rowdata.paySchNo){
		                        h+='<a class="sq-button-hasicon" href="javascript:quateDetailBtn(';
		                        h+="'"+rowdata.id+"',";
		                        if(rowdata.paySchTId){
		                        h+="'"+rowdata.paySchTId+"',";
		                        }else{
		                        	 h+="'',";
		                        }
		                        h+="'"+rowdata.prjPrdId+"'";
		                        h+=')">'+value+'</a>'
		                      }
	                        return h;
	            		}
	            },
	            { display: '产品名称', name: 'prdNm', minWidth: 200 ,enabledSort:true},
	            { display: '产品型号', name: 'prdMdl', minWidth: 140,enabledSort:true},
	            { display: '产品数量', name: 'prdQty', minWidth: 80 , enabledSort:true}
	          /*    {
	                display: '操作',
	                isSort: false,
	                width: 200,
	                render: function (rowdata, rowindex, value){
	                	  var h="";
	                	  if(detailFlag!="true"){
		                        h='<a class="sq-button-hasicon" href="javascript:modifyBtn(';
		                        h+="'"+rowdata.id+"',";
		                        if(rowdata.paySchId){
		                        h+="'"+rowdata.paySchId+"',";
		                        }else{
		                        	 h+="'',";
		                        }
		                        h+="'"+rowdata.prjPrdId+"'";
		                       // if(rowdata.paySchNo){
		                        h+=')"><i class="sqBtnIco_4"></i>修改</a>';
		                      //  }else{
		                      //  h+=')"><i class="sqBtnIco_3"></i>拆分</a>';
		                     //   }
		                        
	                	  }
	                    return h;
	                }
	            }  */ 
	        ],
	        pageSize:100,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        heightDiff:-2,
	        checkbox:false,
	        allowUnSelectRow: true,
            alternatingRow: true,
	        rownumbers:true,
	        enabledEdit: true,
	        usePagerOnLessPagesize: false,
	    });
	    quoteGrid = liger.get("quateGrid");
	    quoteGrid.setHeight(300);
	}
	
	
	//格式化为人民币格式
	function renderAmt(rowdata, rowindex, value) {
        var h="￥" + FormatMoney(value)
        return h;
    }

	//格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value&&value!=''){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
		}
		return dateStr;
	}
	
	//修改
	function modifyBtn(prjPrdDtlId,id,prjPrdId){
		var callback = function(){
			 grid.reload();
		}
		if(null==id){
			id = "";
		}
		if(null==prjPrdDtlId){
			prjPrdDtlId = "";
		}
		if(null==prjPrdId){
			prjPrdId = "";
		}
		Add_navTab('tab_prj_quat_prps'+id,'修改支付表','<%=path%>/project/prjprdpayschm/toAddPage.do?prjId='+prjId+'&&id='+id+'&&prjPrdDtlId='+prjPrdDtlId+'&&prjPrdId='+prjPrdId,callback);
	}

	function detailBtn(prjPrdDtlId,id,prjPrdId){
		var callback = function(){
			 grid.reload();
		}
		if(null==id){
			id = "";
		}
		if(null==prjPrdDtlId){
			prjPrdDtlId = "";
		}
		if(null==prjPrdId){
			prjPrdId = "";
		}
		var editFlag = true;
		Add_navTab('tab_prj_quat_prps'+id,'查看支付表','<%=path%>/project/prjprdpayschm/toAddPage.do?prjId='+prjId+'&&id='+id+'&&prjPrdDtlId='+prjPrdDtlId+'&&prjPrdId='+prjPrdId+'&&detailFlag='+editFlag,callback);
	}
	//查看报价版的支付表信息
	function quateDetailBtn(prjPrdDtlId,id,prjPrdId){
		var callback = function(){
			quateGrid.reload();
		}
		if(null==id){
			id = "";
		}
		if(null==prjPrdDtlId){
			prjPrdDtlId = "";
		}
		if(null==prjPrdId){
			prjPrdId = "";
		}
		var editFlag = true;
		Add_navTab('tab_prj_quat_pay'+id,'查看报价版支付表','<%=path%>/project/prjPrdPaySchTM/toAddPage.do?prjId='+prjId+'&&id='+id+'&&prjPrdDtlId='+prjPrdDtlId+'&&prjPrdId='+prjPrdId,callback);
	}
	
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}
	//删除所选信息
	function removeBtn(){
		var selectedRows = grid.getSelectedRows();
		if(selectedRows.length <1){
			$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warring"});
			return;
		}
		var _ids = [];
		for ( var index in selectedRows) {
			_ids.push(selectedRows[index].id);
		}
		$.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
			if(flag == false)return;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:{ids:JSON.stringify(_ids)},
				url: '<%=path%>/project/prjprddtl/removeByIds.do',
				success:function(msg){
					 if(msg.success == 1){
						 grid.reload();
					 }else{
						 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
					 }
				}
			});
		});
		
	}
</script>

<body class="iframeBody">
	<div class="Wrapper">
        <div>
           <div id="pageInTab" class="pageInTab">
   <!-- <div class="btnsBox">
          <span id="addBtn" onclick="addBtn();" class="sq-button sq-button-hasicon"><i class="sqBtnIco_5"></i>新增</span>
  </div> -->
<!-- <div class="formBtns">
          <span id="removeBtn" onclick="removeBtn();" class="sq-button-round"><i class="sqBtnIco_5"></i>作废</span>
  </div> -->

    <div class="sqPanel">
           <!--  <div class="sqPanel_head inL">
                <span>支付表信息</span>
            </div> -->
            <div class="sqPanel_body">
                 <div id="grid" class="sq-grid"></div>
            </div>
   </div> 
<!--     <div class="sqPanel"  id="quatPrps" style="display: none">
            <div class="sqPanel_head inL">
                <span>报价版支付表信息</span>
            </div>
            <div class="sqPanel_body">
                <div id="quateGrid" class="sq-grid"></div>
            </div>
   </div>  -->
</div>
	</div>
		</div>
			</div>
</body>
</html>